import React, { Component } from 'react'
import {
  InputNumber, Checkbox, Divider, DatePicker, Form, Input, Select, Radio, Row, Col, TreeSelect, message, Modal
} from 'antd';
import { connect } from 'dva';
import "./RightTwo.scss";
import Uploads from './Upload';
import UploadDu from './UploadDu';
import moment from 'moment';
import { getConfig, weixinMpList, goodsList } from '../../../services/fetch'
import { themeList } from '../../../services/information'
import { noImg } from "../../../utils/request";
const TreeNode = TreeSelect.TreeNode;
const FormItem = Form.Item;
const Option = Select.Option;
const RadioGroup = Radio.Group;
const { TextArea } = Input;

@connect(({ add, theme }) => ({
  add: add,
  theme: theme
}))
class RightTwo extends React.PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      radioValue: 2,
      radioValue2: 0,
      showCover: 1,
      editData: '',
      editDatas: [],
      scanNum: 0,
      forwardNum: 0,
      thumbsNum: 0,
      forwardNumPro: 0,
      thumbsNumPro: 0,
      scanNumPro: 0,
      config_json: {},
      mplist: [],
      themeList: [],
      permission: [],
      goodsList: []
    }
  }
  componentDidMount() {
    this.setState({
      permission: JSON.parse(localStorage.getItem('permissionzx')) || []
    })
    this.props.onRef(this);
    let userinfo = localStorage.getItem('userInfo');
    //编辑名称默认为登陆管理员
    if (userinfo) {
      if (typeof userinfo === 'string') {
        userinfo = JSON.parse(userinfo);
      }

      this.props.form.setFieldsValue({
        editor: userinfo.real_name
      });
    }

    let token = localStorage.getItem('token');
    let site_id = localStorage.getItem('site_id');
    // 获取权限信息
    this.props.dispatch({
      type: 'theme/getQuanxian', payload: {
        data: {
          token: token ? token : 'D3F3C235A8884AC96D5133D810B11CF5',
          site_id: site_id ? site_id : '00000000000000000000000000000000'
        }
      }
    })

    window.PubSub.subscribe('pushDataToContent2', this.pushDataToContent)
    this.getFieldsValue = this.getFieldsValue.bind(this)
    this.getThemeList()
    this.state.permission.indexOf('use_goods') > -1 && this.getGoods()
  }

  //获取专题列表
  getThemeList = () => {
    themeList({ index: 1, page_size: 999 }).then(res => {
      console.log(res)
      if (res.data.code == 200 && res.data.data.list) {
        this.setState({
          themeList: res.data.data.list
        })
      }
    })
  }

  //获取带货列表
  getGoods = () => {

    if(JSON.parse(localStorage.getItem('config_json')).saas_domain){ //如果存在凌云域名才会调用凌云相关接口
        goodsList(999).then(res => {
            if (res.data.code == 200) {
      
              this.setState({
                goodsList: res.data.data.rows
              })
      
            } else {
              message.error(res.data.msg)
            }
          })
    }
    
  }

  // componentDidMount() {
  //   this.props.onRef(this);
  //   let userinfo = localStorage.getItem('userInfo');
  //   //编辑名称默认为登陆管理员
  //   if (userinfo) {
  //     if (typeof userinfo === 'string') {
  //       userinfo = JSON.parse(userinfo);
  //     }

  //     this.props.form.setFieldsValue({
  //       editor: userinfo.real_name
  //     });
  //   }

  //   let token = localStorage.getItem('token');
  //   let site_id = localStorage.getItem('site_id');
  //   // 获取权限信息
  //   this.props.dispatch({
  //     type: 'theme/getQuanxian', payload: {
  //       data: {
  //         token: token ? token : '5E495958C87D374D688439E355A5E541',
  //         site_id: site_id ? site_id : '00000000000000000000000000000000'
  //       }
  //     }
  //   })

  //   window.PubSub.subscribe('pushDataToContent2', this.pushDataToContent)

  // }
  componentDidUpdate() {
    if (this.props.add.configJson.weixinPushSwitch && this.props.add.configJson.weixinUrl) {
      this.getMpList();
    }

  }

  pushDataToContent = (item) => {
    console.log('item', item);
    this.props.form.setFieldsValue(item)
  }

  getMpList = () => {
    let wx_url = this.props.add.configJson.weixinUrl;

    if (wx_url && this.state.mplist.length == 0) {
      weixinMpList(wx_url).then((res) => {

        if (res.data.code === 200) {
          this.setState({
            mplist: res.data.data
          })
        }

      })
    }

  }

  /**
   * 树选择
   */
  onChange = (value, label, extra) => {
    console.log(value)
    console.log(label)
    console.log(extra)
    localStorage.setItem('treeSelectedKeys', extra.triggerNode.props.eventKey);
    localStorage.setItem('treeSelectedValue', value);
  }

  onChangeRadio = (e) => {

    this.setState({
      radioValue: e.target.value,
      editDatas: []
    })
    this.props.form.setFieldsValue({
      is_original: e.target.value
    })
  }
  onChangeRadio2 = (e) => {

    this.setState({
      radioValue2: e.target.value,
      editDatas: []
    })
    this.props.form.setFieldsValue({
      is_crond: e.target.value
    })
  }

  onChangeRadio3 = (e) => {

    this.setState({
      radioValue3: e.target.value,
      editDatas: []
    })
    this.props.form.setFieldsValue({
      is_lower_crond: e.target.value
    })
  }
  getFieldsValueTab = () => {
    let data = this.props.form.getFieldsValue()
    return data
  }
  /**
   * 获取表单的值
   */
  getFieldsValue = () => {
    let data = this.props.form.getFieldsValue()
    this.props.form.validateFields()
    if (data.about_artical) {
      data.about_artical.map((item, index) => {
        data[item] = 1
      })
    }
    if (data.about_artical.indexOf('is_comment') < 0) {
      data.is_comment = 0;
    }
    if (data.about_artical.indexOf('is_reprint') < 0) {
      data.is_reprint = 0;
    }
    if (data.about_artical.indexOf('is_ad') < 0) {
      data.is_ad = 0;
    }
    if (data.about_artical.indexOf('is_check_comment') < 0) {
      data.is_check_comment = 0;
    }


    if (this.state.showCover === 2) {
      let arr = data.information_img.split(',');
      if (arr.length < 3) {
        message.error('3图模式，封面图不能少于3张.');
        return false;
      }
    }



    if (this.props.theme.params.class == 'theme' || this.props.theme.params.class == 'theme_edit') { //判断是否是专题资讯
      if (this.state.showCover === 3) {    //是否是无图上传
        return data
      } else {
        if (data.information_img) {
          return data
        }
      }
    } else {
      let validateArr = this.props.form.getFieldsError()
      let isDown = true
      for (const key in validateArr) {
        if (validateArr.hasOwnProperty(key)) {   //判断是否有效验错误
          if (validateArr[key]) {
            isDown = false
            return
          }
        }
      }
      if (isDown) {
        return data
      }
    }
  }
  /**
   * 重置表单
   */
  resetFields = () => {
    this.props.form.resetFields()
    this.setState({
      editDatas: []
    })
  }

  /**
   * 设置默认版面
   */
  setBanMianFields = (data) => {
    this.props.form.setFieldsValue(data)
  }

  /**
   * 引用mch设置默认版面
   */
  setEditor = (data) => {

    if (data.type == 'biz_sobey_video') {
      let mch_img = data.keyFrameUrl;

      if (mch_img) {
        if (this.state.showCover !== 3) {

          let img_arr = this.state.editDatas;

          if (img_arr.length <= 0) {
            img_arr.push(mch_img);
            this.setState({
              showCover: 1,
              editDatas: img_arr
            });
            this.props.form.setFieldsValue({
              information_img: mch_img
            });
          }
          else if (this.state.showCover === 2) {

            if (img_arr.length <= 2) {
              img_arr.push(mch_img);
              this.setState({
                editDatas: img_arr
              })
              this.props.form.setFieldsValue({
                information_img: img_arr.join()
              })
            }

          }
        }
      }
    }

  }
  /**
   * 设置表单值
   */
  setFields = (data) => {
    // 设置点击/转发/点赞默认值
    const config_json = localStorage.getItem('config_json')
    if (typeof (config_json) === 'string') {
      const config = JSON.parse(config_json)
      const { default_forward_num, default_scan_num, default_thumbs_up_num } = data
      data.default_forward_num = !!default_forward_num ? default_forward_num : config.default_forward_num
      data.default_scan_num = !!default_scan_num ? default_scan_num : config.default_scan_num
      data.default_thumbs_up_num = !!default_thumbs_up_num ? default_thumbs_up_num : config.default_thumbs_up_num

    }
    console.log('默认表单值', data);

    //已发布视频不覆盖数据
    if (data.mType && (data.mType == 'video' || data.mType == 'information')) {
      let formData = this.props.form.getFieldsValue();
      if (formData.information_img && formData.information_img != noImg) {

        data.information_img = formData.information_img;
      } else {

        let img = data.information_img;
        if (img) {
          let imgUrl = img.split(",")
          if (imgUrl.length > 1) {
            this.setState({
              showCover: 2,
              editDatas: imgUrl
            })
          } else {
            this.setState({
              showCover: 1,
              editDatas: imgUrl
            })
          }
        } else {
          this.setState({
            showCover: 3
          })
        }
        if (!data.tag) {
          delete data.tag;
        }
        this.props.form.setFieldsValue(data);
      }

      return;
    }

    let img = data.information_img;
    if (img) {
      let imgUrl = img.split(",")
      if (imgUrl.length > 1) {
        this.setState({
          showCover: 2,
          editDatas: imgUrl
        })
      } else {
        this.setState({
          showCover: 1,
          editDatas: imgUrl
        })
      }
    } else {
      this.setState({
        showCover: 3
      })
    }
    if (data.original_url) {
      this.setState({
        radioValue: 2
      })
    }
    if (data.is_crond == 1) {
      this.setState({
        radioValue2: 1
      });
      if (data.crond_time) {
        data.crond_time = moment(data.crond_time, 'YYYY-MM-DD HH:mm:ss');

      }
    }
    if (data.is_lower_crond == 1) {
      this.setState({
        radioValue3: 1
      });
      if (data.lower_crond_time) {
        data.lower_crond_time = moment(data.lower_crond_time, 'YYYY-MM-DD HH:mm:ss');

      }
    }

    data["about_artical"] = [];
    if (data.is_comment == 1) {
      data.about_artical.push('is_comment')
    }
    if (data.is_reprint == 1) {
      data.about_artical.push('is_reprint')
    }
    if (data.is_ad == 1) {
      data.about_artical.push('is_ad')
    }
    if (data.is_check_comment == 1) {
      data.about_artical.push('is_check_comment')
    }

    if (!data.tag) {
      delete data.tag;
    }
    this.props.form.setFieldsValue(data)
    this.setState({
      forwardNumPro: data.forward_num,
      thumbsNumPro: data.thumbs_up_num,
      scanNumPro: data.scan_num,
    })

  }
  /**
   * 封面上传控制
   */
  showCover = (e) => {
    let show = e.target.value;
    this.setState({
      showCover: show,
      editDatas: []
    });

    this.props.form.setFieldsValue({
      information_img: ''
    })

  }
  /**
   * inputNumber 受控
   */
  scanNum = (value) => {
    this.setState({
      scanNum: value
    })
  }
  forwardNum = (value) => {
    this.setState({
      forwardNum: value
    })
  }
  thumbsNum = (value) => {
    this.setState({
      thumbsNum: value
    })
  }
  renderTreeNodes = data =>
    data.map(item => {
      if (item.children) {
        return (
          <TreeNode value={item.code} title={item.name} key={item.id} dataRef={item}>
            {this.renderTreeNodes(item.children)}
          </TreeNode>
        );
      }
      return <TreeNode title={item.name} value={item.code} key={item.code} {...item} />;
    });
  setName = (datas) => { //遍历树  获取id数组
    datas.forEach((item, index) => {
      item.key = item.class_id
      item.title = item.class_name
      item.value = item.class_id
      if (item.children && item.children !== []) {
        this.setName(item.children);
      }
    })

  }

  render() {

    // 设置点击/转发/点赞默认值
    const config_json = localStorage.getItem('config_json')
    let config = {}
    if (typeof (config_json) === 'string') {
      config = JSON.parse(config_json)
    }
    const { default_forward_num, default_scan_num, default_thumbs_up_num } = config

    const { getFieldDecorator } = this.props.form;
    const { plateList, classList, areaList } = this.props.add;

    let treeData = [...classList]

    let obj = {
      class_id: 0,
      class_name: '无'
    }
    treeData.unshift(obj)
    this.setName(treeData)

    const { quanxian } = this.props.theme;
    let data = [];
    plateList.map((item, index) => {
      let obj = {
        key: item.key,
        plate_id: item.plate_id,
        title: item.title,
        children: item.children ? item.children : [],
        value: item.value,
        disabled: item.children && item.children.length > 0 ? true : false
      };
      //去除版面是banner样式的子版面和子版面全是banner的父版面

      // if (item.template_conf.indexOf("banner") > -1  && obj.children.length==0) {
      //
      // }else{
      if (item.children && item.children.length > 0) {
        let child_obj = [];
        item.children.map((i, ins) => {
          // if ((i.template_conf.indexOf("banner") === -1 )) {
          let obj2 = {
            key: i.key,
            plate_id: i.plate_id,
            title: i.title,
            value: i.value,
            template_id: i.template_id,
            template_conf: i.template_conf,
          }
          child_obj.push(obj2);
          // }

        })
        if (child_obj.length > 0) {
          obj.children = child_obj
          data.push(obj)
        }
      } else {
        data.push(obj)

      }

      // }

    })

    let plateList1 = data;
    //正则匹配经度
    const myValidateFields = (rule, values, callback) => {
      var reg = /^[\-\+]?(0?\d{1,2}\.\d{1,5}|1[0-7]?\d{1}\.\d{1,5}|180\.0{1,5})$/;
      if (values) {
        if (!reg.test(values)) {
          callback('请输入正确经度')
        }
      }
      callback()
    };
    //正则匹配纬度
    const myValidateField = (rule, values, callback) => {
      var reg = /^[\-\+]?([0-8]?\d{1}\.\d{1,5}|90\.0{1,5})$/;
      if (values) {
        if (!reg.test(values)) {
          callback('请输入正确的纬度')
        }
      }
      callback()
    };
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 17 },
      },
    };

    // console.log(this.state.thumbsNumPro);

    let { thumbsNumPro, forwardNumPro, scanNumPro, themeList, goodsList } = this.state;
    if (!thumbsNumPro) thumbsNumPro = 0;
    if (!forwardNumPro) forwardNumPro = 0;
    if (!scanNumPro) scanNumPro = 0;

    return (
      <div className="righttwo scroll_box">
        <h3 className='mon_wrap_title'>ᠦᠨᠳᠦᠰᠦᠨ ᠰᠤᠷᠠᠭ</h3>
        <div className='mon_form'>
          <Row gutter={24}>
            <Col span={3}>
              <span className='mon_word' style={{marginLeft: '10px'}}>
                <span style={this.state.showCover === 3 ? { display: 'none' } : { color: 'red' }}>* </span>ᠭᠠᠳᠠᠷ ᠨᠢᠭᠤᠷ
              </span>
            </Col>
            <Col span={3}>
              <RadioGroup onChange={this.showCover} value={this.state.showCover} style={{ marginBottom: '12px' }}>
                <Radio value={1}>ᠨᠢᠭᠡ ᠵᠢᠷᠤᠭᠲᠤ ᠭᠠᠳᠠᠷ</Radio>
                <Radio value={2}>ᠭᠤᠷᠪᠠᠨ ᠵᠢᠷᠤᠭᠲᠤ ᠭᠠᠳᠠᠷ</Radio>
                <Radio value={3}>ᠵᠢᠷᠤᠭ ᠦᠭᠡᠢ</Radio>
              </RadioGroup>
            </Col>
            <Col span={18}>
              {
                this.state.showCover === 3 ? '' : <UploadDu one={this.state.showCover}
                  form={this.props.form} isEdit={this.state.editDatas} />
              }
            </Col>
          </Row>
        </div>
        
        <Form className="mon_form">
          <FormItem
            {...formItemLayout}
            label=""
          >
            {getFieldDecorator('information_img', {
              rules: [{
                required: this.state.showCover === 3 ? false : true, message: '请上传封面图片',
              }],
            })(
              <Input style={{ display: 'none' }} />
            )}
          </FormItem>
          <Row gutter={24} style={{padding: '0 10px'}}>
            {this.props.theme.params.class && this.props.theme.params.class == 'theme' || this.props.theme.params.class == 'theme_edit' ? [] :
              <Col span={8}>
                <FormItem
                  {...formItemLayout}
                  label="ᠮᠡᠳᠡᠭᠡ ᠵᠠᠩᠭᠢ᠎ᠶᠢᠨ ᠠᠩᠭᠢᠯᠠᠯ"
                >
                  {getFieldDecorator('class_id')(
                    // <Select placeholder="请选择资讯分类" size="small">
                    //   <Option key={0} value={0}>无</Option>
                    //   {
                    //     classList.map((item, index) => {
                    //       return <Option key={index} value={item.class_id}>{item.class_name}</Option>
                    //     })
                    //   }
                    // </Select>
                    <TreeSelect
                      dropdownClassName='mon_select_tree'
                      dropdownStyle={{ maxHeight: 400 }}
                      dropdownMatchSelectWidth
                      placeholder=""
                      allowClear
                      treeData={treeData}
                    >
                    </TreeSelect>
                  )}
                </FormItem>
              </Col>
            }
            {this.props.theme.params.class && this.props.theme.params.class == 'theme' || this.props.theme.params.class == 'theme_edit' ? [] :
              <Col span={8}>
                <FormItem
                  {...formItemLayout}
                  label="ᠮᠡᠳᠡᠭᠡ ᠵᠠᠩᠭᠢ᠎ᠶᠢᠨ ᠨᠢᠭᠤᠷ"
                >
                  {getFieldDecorator('plate_id', {
                    rules: [{
                      required: true, message: '请选择资讯版面',
                    }],
                  })(
                    <TreeSelect
                      size="small"
                      dropdownStyle={{ maxHeight: 400 }}
                      dropdownMatchSelectWidth
                      placeholder=""
                      treeData={plateList1}
                      multiple
                      treeDefaultExpandAll
                      onChange={this.onChange}
                      multiple
                    />
                  )}
                </FormItem>
              </Col>
            }
            <Col span={8}>
              <FormItem
                {...formItemLayout}
                label="ᠲᠤᠰᠭᠠᠢ ᠰᠡᠳᠦᠪ"
              >
                {getFieldDecorator('theme_id')(
                  <Select placeholder="" size="small" showSearch optionFilterProp="children">
                    <Option key={0} value={0}>无</Option>
                    {
                      themeList.map((item, index) => {
                        return <Option key={index} value={item.theme_id}>{item.theme_name}</Option>
                      })
                    }
                  </Select>
                )}
              </FormItem>
            </Col>
          </Row>
          
          <Row gutter={24} style={{padding: '0 10px'}}>
            {this.state.permission.indexOf('use_goods') > -1 &&
              <Col span={6}>
              <FormItem
                {...formItemLayout}
                label="ᠪᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠭᠠᠭᠤᠯᠬᠤ"
              >
                {getFieldDecorator('goods_id')(
                  <Select placeholder="" size="small">
                    <Option key={0} value={0}>ᠬᠣᠭᠤᠰᠤᠨ</Option>
                    {
                      goodsList.map((item, index) => {
                        return <Option key={item.id} value={item.id}>{item.name}</Option>
                      })
                    }
                  </Select>
                )}
              </FormItem>
              </Col>
            }
            
            <Col span={6}>
              <FormItem
                {...formItemLayout}
                label="ᠨᠠᠢᠷᠠᠭᠤᠯᠤᠭᠴᠢ"
              >
                {getFieldDecorator('editor')(
                  <Input placeholder="" size="small" />
                )}
              </FormItem>
            </Col>
            <Col span={6}>
              <FormItem
                {...formItemLayout}
                label="ᠰᠤᠷᠪᠤᠯᠵᠢᠯᠠᠭᠴᠢ"
              >
                {getFieldDecorator('reporter')(
                  <Input placeholder="" size="small" />
                )}
              </FormItem>
            </Col>
            <Col span={6}>
              <FormItem
                {...formItemLayout}
                label="ᠵᠣᠬᠢᠶᠠᠭᠴᠢ"
              >
                {getFieldDecorator('author')(
                  <Input placeholder="" size="small" />
                )}
              </FormItem>
            </Col>
            <Col span={6}>
              <FormItem
                {...formItemLayout}
                label="ᠢᠷᠡᠯᠲᠡ"
              >
                {getFieldDecorator('resource')(
                  <Input placeholder="" size="small" />
                )}
              </FormItem>
            </Col>
            {this.state.permission.indexOf('info_tag') > -1 &&
              <Col span={6}>
                <FormItem
                  {...formItemLayout}
                  label="ᠲᠡᠮᠳᠡᠭ"
                >
                  {getFieldDecorator('tag', {

                  })(
                    <Select className="keyInput" mode="tags" style={{ width: '100%' }} tokenSeparators={['|']}></Select>,
                  )}

                </FormItem>
              </Col>
            }
          </Row>
          

          <Divider />
          {this.state.permission.indexOf('info_lbs') > -1 &&
            <FormItem
              {...formItemLayout}
              label="区域"
            >
              {getFieldDecorator('area_code')(
                <TreeSelect
                  size="small"
                  dropdownStyle={{ maxHeight: 400 }}
                  dropdownMatchSelectWidth
                  placeholder="请选择区域"
                >
                  {this.renderTreeNodes(areaList)}
                </TreeSelect>
              )}
            </FormItem>
          }

          <h3 className='mon_wrap_text'>ᠤᠷᠤᠨ ᠪᠠᠢᠷᠢ<span style={{ fontSize: '15px' }}></span></h3>
          <FormItem
            {...formItemLayout}
            mon_class='mon_wrap_label'
            label="ᠤᠷᠤᠨ ᠪᠠᠢᠷᠢ"
          >
            {getFieldDecorator('position')(
              <Input size="small" />
            )}
          </FormItem>
          <FormItem
            {...formItemLayout}
            mon_class='mon_wrap_label'
            label="ᠤᠷᠲᠤᠷᠢᠭ᠎"
          >
            {getFieldDecorator('longitude', {
              rules: [{
                validator: myValidateFields
              }]
            })(
              <Input size="small" placeholder="-180.0～+180.0" />
            )}
          </FormItem>
          <FormItem
            {...formItemLayout}
            mon_class='mon_wrap_label'
            label="ᠥᠷᠭᠡᠷᠢᠭ"
          >
            {getFieldDecorator('latitude', {
              rules: [{
                validator: myValidateField
              }]
            })(
              <Input size="small" placeholder="-90.0～+90.0" />
            )}
          </FormItem>
          <Divider />

          <Row gutter={24}>
            <Col span={5}>
              <h3 className='mon_word'>ᠵᠣᠬᠢᠶᠠᠯ᠎ᠤᠨ ᠲᠣᠬᠢᠷᠠᠭᠤᠯᠤᠯᠲᠠ</h3>
            </Col>

            <Col span={18}>
              <FormItem mon_class="mon_form">
                {getFieldDecorator('about_artical', { initialValue: ['is_comment', 'is_reprint', 'is_ad'] })(
                  <Checkbox.Group style={{ width: '200px' }}>
                    <Row gutter={24}>
                      <Col span={8}><Checkbox value="is_comment">ᠰᠢᠭᠦᠮᠵᠢ ᠎ᠵᠢ ᠵᠥᠪᠰᠢᠶᠡᠷᠡᠬᠦ</Checkbox></Col>
                      {/* <Col span={24}><Checkbox value="is_ad">允许广告</Checkbox></Col> */}
                      <Col span={8}><Checkbox value="is_check_comment">ᠰᠢᠭᠦᠮᠵᠢ ᠎ᠵᠢ ᠬᠢᠨᠠᠬᠤ (<span style={{ color: "#999" }}>ᠱᠢᠭᠦᠮᠵᠢ ᠎ᠵᠢ ᠬᠥᠮᠦᠨ ᠬᠢᠨᠠᠬᠤ</span>)</Checkbox></Col>
                      <Col span={8}><Checkbox value="is_reprint">ᠱᠢᠯᠵᠢᠭᠦᠯᠦᠨ ᠨᠡᠢᠲᠡᠯᠡᠬᠦ᠎ᠶᠢ ᠵᠥᠪᠱᠢᠶᠡᠷᠡᠬᠦ（分）</Checkbox></Col>
                    </Row>
                  </Checkbox.Group>
                )}
              </FormItem>
            </Col>
          </Row>
          
          
          <Divider />
          <Row gutter={24} style={{paddingLeft: '15px'}}>
            <Col span={8}>
              <FormItem
                {...formItemLayout}
                label="ᠠᠩᠬᠠᠨ᠎ᠤ ᠡᠭᠦᠳᠦᠯᠲᠡ ᠮᠥᠨ ᠡᠰᠡᠬᠥ"
              >
                <div mon_class='mon_group'>
                  {getFieldDecorator('is_original', { initialValue: 2 })(
                    <RadioGroup  onChange={this.onChangeRadio}>
                      <Radio value={1}>ᠮᠥᠨ</Radio>
                      <Radio value={2}>ᠪᠢᠰᠢ</Radio>
                    </RadioGroup>
                  )}
                 </div>
              </FormItem>
            </Col>
            <Col span={13} style={this.state.radioValue === 2 ? { display: "none" } : {}}>
              <FormItem
                {...formItemLayout}
                mon_class='mon_label1'
                label="ᠠᠩᠬᠠᠨ᠎ᠤ ᠡᠭᠦᠳᠦᠯᠲᠡ᠎ᠶᠢᠨ ᠢᠯᠡᠷᠬᠡᠢᠯᠡᠯᠲᠡ"
                style={this.state.radioValue === 2 ? { display: "none" } : {}}
              >
                <div mon_class='mon_textarea'>
                  {getFieldDecorator('original_intro')(
                    <TextArea placeholder="" autosize={{ minRows: 6, maxRows: 10 }} />
                  )}
                </div>
              </FormItem>
            </Col>
            <Col span={13} style={this.state.radioValue === 1 ? { display: "none" } : {}}>
              <FormItem
                {...formItemLayout}
                mon_class='mon_label1'
                label="ᠤᠭ ᠵᠣᠬᠢᠶᠠᠯ᠎ᠤᠨ ᠬᠣᠯᠪᠤᠭᠠᠰᠤ"
                style={this.state.radioValue === 1 ? { display: "none" } : {}}
              >
                <div mon_class='mon_textarea'>
                  {getFieldDecorator('original_url')(
                    <TextArea placeholder="" autosize={{ minRows: 6, maxRows: 10 }} />
                  )}
                </div>
              </FormItem>
            </Col>
          </Row>
          <Divider />
          <Row gutter={24} style={{paddingLeft: '15px'}}>
            <Col span={12}>
              <FormItem
                {...formItemLayout}
                label="ᠲᠣᠭᠲᠠᠭᠰᠠᠨ ᠴᠠᠭ᠎ᠲᠤ ᠭᠠᠷᠭᠠᠬᠤ"
              >
                <div mon_class='mon_group'>
                  {getFieldDecorator('is_crond', { initialValue: 0 })(
                    <RadioGroup onChange={this.onChangeRadio2}>
                      <Radio value={1}>ᠲᠡᠢᠮᠦ</Radio>
                      <Radio value={0}>ᠪᠢᠱᠢ</Radio>
                    </RadioGroup>
                  )}
                </div>
              </FormItem>
            </Col>
            <Col span={12}>
              <FormItem
                {...formItemLayout}
                label="ᠲᠣᠭᠲᠠᠭᠰᠠᠨ ᠴᠠᠭ᠎ᠲᠤ ᠪᠠᠭᠤᠯᠭᠠᠬᠤ"
              >
                <div mon_class='mon_group'>
                  {getFieldDecorator('is_lower_crond', { initialValue: 0 })(
                    <RadioGroup onChange={this.onChangeRadio3}>
                      <Radio value={1}>ᠲᠡᠢᠮᠦ</Radio>
                      <Radio value={0}>ᠪᠢᠱᠢ</Radio>
                    </RadioGroup>
                  )}
                 </div>
              </FormItem>
            </Col>
          </Row>

          <FormItem
            {...formItemLayout}
            mon_class='mon_wrap_label'
            label="ᠭᠠᠷᠭᠠᠬᠤ ᠴᠠᠭ"
            style={this.state.radioValue2 != 1 ? { display: "none" } : {}}
          >
            {getFieldDecorator('crond_time')(
              <DatePicker style={{ width: "200px" }} showTime format="YYYY-MM-DD HH:mm:ss" />
            )}
          </FormItem>
        
          <FormItem
            {...formItemLayout}
            mon_class='mon_wrap_label'
            label="ᠪᠠᠭᠤᠯᠭᠠᠬᠤ ᠴᠠᠭ"
            style={this.state.radioValue3 != 1 ? { display: "none" } : {}}
          >
            {getFieldDecorator('lower_crond_time')(
              <DatePicker style={{ width: "200px" }} showTime format="YYYY-MM-DD HH:mm:ss" />
            )}
          </FormItem>

          {(this.props.add.configJson.isVirtualViewData !== false && quanxian.indexOf("information/xuni") > -1) ? <><Divider />
            <FormItem
              label={<span className="title">点击量<span className="hs">（点击量 = 基数 + 系数*实际数）</span></span>}
            >
              <span>
                {getFieldDecorator('default_scan_num', { initialValue: default_scan_num })(
                  <InputNumber placeholder="基数" min={0} style={{ width: '65px' }} onChange={this.scanNum} />
                )}
                                +  {getFieldDecorator('scan_coefficient', { initialValue: 1 })(
                  <InputNumber placeholder="系数" min={0} style={{ width: '65px' }} onChange={this.scanNum} />
                )} * {scanNumPro}（实际数） = {scanNumPro * parseInt(this.props.form.getFieldValue('scan_coefficient')) + parseInt(this.props.form.getFieldValue('default_scan_num'))}</span>
            </FormItem>
            <FormItem
              label={<span className="title">转发量<span className="hs">（转发量 = 基数 + 系数*实际数）</span></span>}
            >
              <span>
                {getFieldDecorator('default_forward_num', { initialValue: default_forward_num })(
                  <InputNumber placeholder="基数" min={0} style={{ width: '65px' }} onChange={this.forwardNum} />
                )}
                                + {getFieldDecorator('forward_coefficient', { initialValue: 1 })(
                  <InputNumber placeholder="系数" min={0} style={{ width: '65px' }} onChange={this.scanNum} />
                )} *  {forwardNumPro}（实际数） = {forwardNumPro * parseInt(this.props.form.getFieldValue('forward_coefficient')) + parseInt(this.props.form.getFieldValue('default_forward_num'))}</span>
            </FormItem>
            <FormItem
              label={<span className="title">点赞量<span className="hs">（点赞量 = 基数 + 系数*实际数）</span></span>}
            >
              <div>
                {getFieldDecorator('default_thumbs_up_num', { initialValue: default_thumbs_up_num })(
                  <InputNumber placeholder="基数" min={0} style={{ width: '65px' }} onChange={this.thumbsNum} />
                )}
                                + {getFieldDecorator('thumbs_up_coefficient', { initialValue: 1 })(
                  <InputNumber placeholder="基数" min={0} style={{ width: '65px' }} onChange={this.thumbsNum} />
                )} * {thumbsNumPro}（实际数） = {thumbsNumPro * parseInt(this.props.form.getFieldValue('thumbs_up_coefficient')) + parseInt(this.props.form.getFieldValue('default_thumbs_up_num'))}</div>
            </FormItem></> : null}

          <Divider />
          {this.props.add.configJson.weixinPushSwitch && this.props.add.configJson.weixinUrl ?

            <FormItem
              label="选择推送的公众号"
            >
              {getFieldDecorator('weixin_mpid')(
                <Checkbox.Group >
                  <Row>
                    {
                      this.state.mplist.map((item) => {
                        return (
                          <div >
                            <Col key={item.id} style={{ marginBottom: '15px', width: "100%" }} span={8}><Checkbox value={item.id}>{item.name}</Checkbox></Col>

                          </div>

                        )
                      })
                    }
                  </Row>
                </Checkbox.Group>
              )}
            </FormItem>
            : ''
          }

        </Form>
      </div>
    )
  }
}

const RightTwos = Form.create()(RightTwo);
export default RightTwos;
